﻿@using Xunit;
@inherits TestContext
@code
{
    [Inject]
    private LibraryConfiguration LibraryConfiguration { get; set; } = new LibraryConfiguration();

    public FluentSliderTests()
    {
        JSInterop.Mode = JSRuntimeMode.Loose;
        Services.AddSingleton(LibraryConfiguration);
    }

    [Fact]
    public void FluentSlider_Default()
    {
        // Arrange && Act
        int value = 3;
        var cut = Render(@<FluentSlider Min="0" Max="100" Step="10" @bind-Value="@value"></FluentSlider>);

        // Assert
        cut.Verify();
    }

    [Fact]
    public void FluentSlider_Horizontal()
    {
        // Arrange && Act
        var cut = Render(@<FluentSlider Min="0" Max="100" Step="10" Orientation="Orientation.Horizontal"></FluentSlider>);

        // Assert
        cut.Verify();
    }

    [Fact]
    public void FluentSlider_Vertical()
    {

        // Arrange
        var cut = Render(@<FluentSlider Min="0" Max="100" Step="10" Orientation="Orientation.Vertical"></FluentSlider>);

        // Assert
        cut.Verify();
    }

    [Fact]
    public void FluentSlider_Double()
    {
        double value = 3.5;
        // Arrange
        var cut = Render(@<FluentSlider Min="-1.50" Max="7.0" Step="0.5" @bind-Value="@value"></FluentSlider>);

        // Assert
        cut.Verify();
    }

    [Fact]
    public void FluentSlider_WithLabel()
    {
        JSInterop.Mode = JSRuntimeMode.Loose;

        // Arrange && Act       
        var cut = Render(@<FluentSlider Id="xxx" Min="0" Max="100" Step="10" Label="label"></FluentSlider>);

        // Assert
        cut.Verify();
    }

    [Fact]
    public void FluentSlider_WithLabelTemplate()
    {
        // Arrange && Act
        var cut = Render(@<FluentSlider Min="0" Max="100" Step="10" >
        <LabelTemplate><strong>label</strong></LabelTemplate>
        </FluentSlider>);

        // Assert
        cut.Verify();
    }

    [Fact]
    public void FluentSlider_Binding()
    {
        // Arrange
        int value = 3;
        var cut = Render(@<FluentSlider Min="0" Max="10" Step="1" @bind-Value="@value"></FluentSlider>);

        // Act
        var slider = cut.Find("fluent-slider");
        slider.TriggerEvent("onsliderchange", new ChangeEventArgs { Value = 2 });

        // Assert
        Assert.Equal(2, value);
    }
}
